import { Injectable } from '@angular/core';
import * as localForage from 'localforage';

@Injectable({
  providedIn: 'root'
})
export class LocalForageService {


  constructor() {
    //console.log(localForage)
    // localForage.config({
    //   name: 'myApp'
    // });
  }

  public getItem<T>(key: string): Promise<T | null> {
    return localForage.getItem<T>(key);
  }

  public setItem(key: string, value: any): Promise<void> {
    return localForage.setItem(key, value);
  }

  public removeItem(key: string): Promise<void> {
    return localForage.removeItem(key);
  }

  public clear(): Promise<void> {
    return localForage.clear();
  }

  public length(): Promise<number> {
    return localForage.length();
  }

  public key(index: number): Promise<string | null> {
    return localForage.key(index);
  }
}

